package com.myapi.ModelPoker;
import java.util.*;



public abstract class RankedHand implements Comparable {
	private int rank;
	private Set<Card> cards;
	
	public RankedHand(int rank, Set<Card> cards) {
		this.cards = cards;
		this.rank = rank;
	}
	
	public int getRank() {
		return rank;
	}
	
	public Set<Card> getCards() {
		return cards;
	}
	
	/**
	 * compares two sets of cards to see which has higher cards (for determining higher kickers when hand rank is the same)
	 * @param cards1 First Cards
	 * @param cards2 Seconde Cards
	 * @return 1 -1 0 to be conform with the type comparable
	 */
	public int compareHighCards(Set<Card> cards1, Set<Card> cards2) {
		TreeSet<Card> treeCards1 = new TreeSet<Card>(cards1);
		TreeSet<Card> treeCards2 = new TreeSet<Card>(cards2);
		for(int i = 0; i < 5; i++) {
			Card card1 = treeCards1.first();
			treeCards1.remove(card1);
			int value1 = card1.getValue();
			Card card2 = treeCards2.first();
			treeCards2.remove(card2);
			int value2 = card2.getValue();
			if(value1 > value2)
				return 1;
			else if(value1 < value2)
				return -1;				
		}
		return 0;
	}
        
        public abstract String rankToString();
	
	public abstract int compareTo(Object o);
		
}
